package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级模块")
public class nursingLevelController extends BaseController {
    @Autowired
    private NursingLevelService nursingLevelService;

    /**
     * 查询所有护理等级
     * @return
     */
    @ApiOperation("查询所有狐狸等级")
    @GetMapping("/listAll")
    private ResponseResult<List<NursingLevelVo>> GetAllNursingLevel(){
        List<NursingLevelVo> nursingLevelVos =  nursingLevelService.GetAllPlanLevel();
        return success(nursingLevelVos);
    };

    /**
     * 新增护理等级
     * @param nursingLevelDto
     * @return
     */
    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    private ResponseResult InsertPlanLevel(
            @RequestBody
            @ApiParam(value = "新增护理等级数据",required = true)
            NursingLevelDto nursingLevelDto){
        nursingLevelService.addlevel(nursingLevelDto);
        return success();
    }

    /**
     * 分页查询护理等级
     * @param pageNum
     * @param pageSize
     * @param name
     * @param status
     * @return
     */
    @GetMapping("/listByPage")
    @ApiOperation("分页查询护理等级")
    private  ResponseResult<PageResponse<NursingLevelVo>> getLevelPage(
            @RequestParam("pageNum") @ApiParam(value = "页码") Integer pageNum,
            @RequestParam("pagSize") @ApiParam(value = "每页大小") Integer pageSize,
            @RequestParam(value = "name",required = false) @ApiParam(value = "护理等级名称") String name,
            @RequestParam(value = "status",required = false ) @ApiParam(value = "护理等级状态") Integer status

    ){
       PageResponse<NursingLevelVo> nursingLevelVoPageResponse =  nursingLevelService.getPage(pageNum,pageSize,name,status);
       return success(nursingLevelVoPageResponse);
    }

    /**
     * 根据id查询护理等级
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理等级")
    private ResponseResult<NursingLevelVo> getById(@PathVariable Long id){
        NursingLevelVo nursingLevelVo = nursingLevelService.getByid(id);
        return success(nursingLevelVo);
    }

    /**
     * 修改护理等级
     * @param nursingLevelDto
     * @return
     */
    @PutMapping("/update")
    @ApiOperation("修改护理等级")
    private ResponseResult updateLevel(@RequestBody @ApiParam("修改护理等级信息") NursingLevelDto nursingLevelDto){
        nursingLevelService.updatelevel(nursingLevelDto);
        return success();
    }

    /**
     * 删除护理等级
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation("根据id删除护理等级")
    private ResponseResult deletelevel(@PathVariable @ApiParam("删除护理等级id") Long id){
        nursingLevelService.deleteByid(id);
        return success();
    }

    /**
     * 根据id禁用或启用护理等级
     * @param id
     * @param status
     * @return
     */
    @PutMapping("/{id}/status/{status}")
    @ApiParam("禁用/启用护理等级")
    private ResponseResult enableOrDisable(
            @ApiParam("护理等级id") @PathVariable Long id,
            @ApiParam("护理等级状态") @PathVariable Integer status){
        nursingLevelService.updatestatus(id,status);
        return success();
    }

}
